package com.newly.api.sys.feign;

import com.newly.common.base.constants.ServerUriConstant;
import com.newly.common.base.entity.R;
import com.newly.common.base.entity.sys.operLogger.dto.OperLoggerDto;
import com.newly.common.base.entity.valid.Insert;
import com.newly.common.base.entity.valid.Update;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * @program: newly-parent
 * @remark: 操作日志
 * @author: guan
 * @create: 2021-12-04 17:52
 */
@Api(tags = "操作日志接口")
@FeignClient(path = ServerUriConstant.NEWLY_SYS_OPERATION_LOGGER, name = ServerUriConstant.NEWLY_SYS_SERVICE_NAME)
public interface OperLoggerClient {

    @ApiOperation("添加操作日志")
    @PostMapping("/create")
    R create(@Validated(Insert.class) @RequestBody OperLoggerDto operLoggerDto);

    @ApiOperation("修改操作日志")
    @PutMapping("/change")
    R change(@Validated(Update.class) @RequestBody OperLoggerDto operLoggerDto);

    @ApiOperation("查询操作日志")
    @GetMapping("/list")
    R list(@NotNull(message = "offset can't be empty") @RequestParam(value = "offset") Integer offset,
           @NotNull(message = "limit can't be empty") @RequestParam(value = "limit") Integer limit,
           @RequestParam(value = "abilityCode", required = false) Integer abilityCode,
           @RequestParam(value = "fromTime", required = false) String fromTime,
           @RequestParam(value = "toTime", required = false) String toTime,
           @RequestParam(value = "keyword", required = false) String keyword);

    @ApiOperation("通过id查询操作日志")
    @GetMapping("/queryByIds")
    R queryByIds(@NotEmpty(message = "logIds can't be empty") @RequestParam("logIds") List<String> logIds);

    @ApiOperation("通过id删除操作日志")
    @DeleteMapping("/deleteByIds")
    R deleteByIds(@NotEmpty(message = "logIds can't be empty")
                  @RequestParam("logIds") List<String> logIds);

    @ApiOperation("清空日志")
    @DeleteMapping("/clear")
    R clear();

    @ApiOperation("查询操作")
    @GetMapping("/queryOperation")
    R queryOperation();
}
